package Dao;

import domain.yuliang;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import uilts.C3P0utils;

import java.sql.SQLException;
import java.util.List;

public class yuliangDao {

    C3P0utils c3P0utils=new C3P0utils();

    /*查询所有信息;    单一查询*/
    public List<yuliang> findAll(String sql,List list) throws SQLException {
        QueryRunner queryRunner = new QueryRunner(c3P0utils.getDataSource());
        return queryRunner.query(sql,new BeanListHandler<yuliang>(yuliang.class),list.toArray());
    }

    /*修改信息*/
    public int update(String sql, List list){
        return c3P0utils.executeUpdate(sql,list.toArray());
    }

    /*删除信息*/

    public int delete(String sql,List list){
        return c3P0utils.executeUpdate(sql,list.toArray());
    }
    /*新增信息*/

    public int xz(String sql,List list) throws SQLException {
        QueryRunner queryRunner = new QueryRunner(c3P0utils.getDataSource());
        return queryRunner.update(sql, list.toArray());

    }

}
